package com.dgh.school.mapper;

import com.dgh.school.bean.Department;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 部门管理的持久层
 *
 */

@Mapper
public interface DepartmentMapper {

    @Select("select * from department")
    List<Department> selectAll() throws Exception;

    // 根据id删除数据
    @Delete("delete from department where did = #{id}")
    void deleteById(int id) throws Exception;

    // 插入数据
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert("insert into department values (default, #{dname}, #{dnumber},  #{dfunction})")
    void insert(Department de) throws Exception;


    @Update("update department set dname = #{dname},dnumber = #{dnumber},dfunction = #{dfunction} where dname = #{dname}")
    void update(Department de) throws Exception;
}
